const fs = require("fs");

let filePromise = new Promise((resolve, reject) => {
    fs.readFile("./test/a.txt", (err, data) => {
        if (err) reject(err);
        if (data) resolve([data]);
    });
});

filePromise.then(value => {
    return new Promise((resolve, reject) => {
        fs.readFile("./test/b.txt", (err, data) => {
            if (err) reject(err);
            if (data) { 
                value.push(data);
                resolve(value);
            }
        });
    });
}).then(value => {
    return new Promise((resolve, reject) => {
        fs.readFile("./test/c.txt", (err, data) => {
            if (err) reject(err);
            if (data) { 
                value.push(data);
                resolve(value);
            }
        });
    });
}).then(data=>{
    console.log(data.join("\r\n"));
});
